<include file="Inc/html_header" />
<div class="mtop10">
    <table class="table table-bordered table-hover">
        <thead>
            <tr>
                <th colspan="3"><i class="icon icon-home"></i> <a href="<?php echo U('framework/logs');?>">TP日志</a> <i class="icon icon-double-angle-right"></i> <a href="javascript:;"><?php echo $d_name; ?></a></th>
            </tr>
            <tr>
                <th colspan="3">
                    <a href="javascript:;"><label><input class="sx_input" type="checkbox" onclick="checkAll(this, 'xxx[]')" />全选</label></a>&nbsp;&nbsp;&nbsp;
                    <a href="javascript:;" onclick="$('.sx_input').attr('checked', false);">重选</a>&nbsp;&nbsp;&nbsp;
                    <a href="javascript:;" onclick="deleteMulti()">删除</a>
                </th>
            </tr>
        </thead>
        <tbody>
            <?php
            if( ! empty($files)){
                foreach($files as $v){
                    $file = $dir.'/'.$v;
                    $file_name = $d_name.'/'.$v;
            ?>
            <tr>
                <td><input class="sx_input" type="checkbox" name="xxx[]" value="<?php echo $file_name ;?>" />&nbsp;&nbsp;<a href="<?php echo U('framework/logs_files_content', array('d_name'=>$d_name, 'f_name'=>$v)) ;?>"><i class="icon-file"></i> <?php echo $v ;?></a> </td>
                <td width="100"><?php echo formatBytes(filesize($file)) ; ?></td>
                <td width="50"><a href="javascript:;" class="sys-btn" onclick="delOne('<?php echo $file_name ;?>')">删除</a></td>
            </tr>
            <?php }} ?>
        </tbody>
    </table>
</div>
<script type="text/javascript">
    function deleteMulti()
    {
        if( ! confirm('确定删除？')){ return; }
        
        var files = [];
        var obj = $("input[name='xxx[]']");

        obj.each(function(){
            if($(this).is(':checked')){
                files.push($(this).val());
            }
        });
        
        if(files.length < 1){
            alert('请选择');
            return;
        }
        
        submitDeleteForm(files);
    }
    
    function delOne(file_name)
    {
        if( ! confirm('确定删除？')){ return; }
        file_name = $.trim(file_name);
        if(file_name == ''){ alert('参数错误'); return; }
        var files = [];
        files.push(file_name);
        
        submitDeleteForm(files);
    }
    
    function submitDeleteForm(files)
    {
        $.ajax({
            url:'<?php echo U('framework/del_files');?>',
            data:{'files':files},
            type:'post',
            dataType:'json',
            success:function(msg){
                if(msg.st != 'y'){
                    alert(msg.note);
                }
                location.reload();
            },
            error:function(){
                alert('网络繁忙，请稍后重试。');
            }
        });
    }
</script>
<include file="Inc/html_footer" />